import { IPSSystem } from '../ipssystem';
import { IPSAppPDTView } from './ipsapp-pdtview';
import { IPSApplication } from './ipsapplication';
import { IPSAppView } from './view/ipsapp-view';
import { IPSSysPDTView } from '../res/ipssys-pdtview';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSAppPDTViewImpl extends PSModelObjectImpl implements IPSAppPDTView {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappview: IPSAppView | null = null;

  getPSAppView(): IPSAppView | null {
    if (this.psappview != null) return this.psappview;
    const value = this.M.getPSAppView;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappview = ipsapplication.findPSAppView(value);
    }
    return this.psappview;
  }

  get psAppView(): IPSAppView | null {
    return this.getPSAppView();
  }

  getPSAppViewMust(): IPSAppView {
    const value = this.getPSAppView();
    if (value == null) {
      throw new Error('未指定目标应用视图');
    }
    return value;
  }

  protected pssyspdtview: IPSSysPDTView | null = null;

  getPSSysPDTView(): IPSSysPDTView | null {
    if (this.pssyspdtview != null) return this.pssyspdtview;
    const value = this.M.getPSSysPDTView;
    if (value == null) {
      return null;
    }
    const ipssystem = this.getParentPSModelObject('IPSSystem') as IPSSystem;
    if (ipssystem != null) {
      this.pssyspdtview = ipssystem.findPSSysPDTView(value);
    }
    return this.pssyspdtview;
  }

  get psSysPDTView(): IPSSysPDTView | null {
    return this.getPSSysPDTView();
  }

  getPSSysPDTViewMust(): IPSSysPDTView {
    const value = this.getPSSysPDTView();
    if (value == null) {
      throw new Error('未指定系统预置视图');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSAppPDTViewImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.IPSAppPDTView') return true;
    return super.instanceof(cls);
  }
}
